package com.ruimei.service.impl;

import com.ruimei.entitys.ClassNews;
import com.ruimei.mapper.ClassNewsMapper;
import com.ruimei.service.ClassNewsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ClassNewsServiceImpl  implements ClassNewsService {

    @Resource
    ClassNewsMapper mapper;

    @Override
    public Map<String, Object> addClassNews(ClassNews classNews) {

        Map<String, Object> map = new HashMap();

        Integer i = mapper.addClassNews(classNews);
        if(i.intValue() == 1){
            map.put("status", Boolean.valueOf(true));
            map.put("message", "添加成功");
        }else{
            map.put("status", Boolean.valueOf(false));
            map.put("message", "添加失败");
        }

        return map;
    }

    @Override
    public Map<String, Object> getClassNews(ClassNews classNews) {
        Map<String, Object> map = new HashMap();
        List<ClassNews> list = mapper.getClassNews(classNews);
        map.put("status", Boolean.valueOf(true));
        map.put("message", "查询成功");
        map.put("count", Integer.valueOf(list.size()));
        map.put("data", list);

        return map;
    }

    @Override
    public Map<String, Object> getClassNews(String classId, String beginTime,String endTime){
        Map<String, Object> map = new HashMap();
        List<ClassNews> list = mapper.getClassNewsT(classId,beginTime,endTime);
        map.put("status", Boolean.valueOf(true));
        map.put("message", "查询成功");
        map.put("count", Integer.valueOf(list.size()));
        map.put("data", list);

        return map;
    }

}
